var details = null;
var progressHistory = "";

var loadData = function(){
	var details_str =getCookie("opp_details");
	if(!details_str){
		return;
	}
	details= JSON.parse(details_str);
};

var showData = function(){
	if(!details){
		alert("数据加载错误！");
		return;
	}
	$("#order_name").html(details.k1+"-"+details.k2+"-"+details.id);
	$("#order_id").html(details.id);
	$("#opp_type").html(details.k1);
	$("#status").html(details.k3);
	$("#progress_history").html(details.k4);
	progressHistory=details.k4;
	
};

var addProgressSucc=function(outData){
	console.log("addSucc");
	alert("提交成功");
	$("#submit").html("提交");
   	if($("#submit").hasClass("am-disabled")){
		$("#submit").removeClass("am-disabled")
	}
	window.history.go(-1);
};


$(function(){
   loadData();
   console.info(details);
   showData();


    $("#submit").on("click",function(){
    	if(!$("#progress").val()){
    		alert("不能为空！");
    		return;
    	}
      	$("#submit").html("<i class='am-icon-spinner am-icon-spin'></i>&nbsp&nbsp&nbsp&nbsp提交中……");
    	if(!$("#submit").hasClass("am-disabled")){
    		$("#submit").addClass("am-disabled")
    	}
    	var params={"id":$("#order_id").html(),"progress":progressHistory+$("#progress").val()+"<br>"};
    	sendDzgPostAjax(params,"../../../opponent/addProgress",addProgressSucc);
     });

	
});